/**
 * @description 生成统计列表
 * @author superrui
 */

const Mock = require("mockjs");
const Random = Mock.Random;
const getComponentList = require("./getComponentList");
function getStatList(len = 20) {
  //生成组件列表
  const componentList = getComponentList();
  const res = [];
  for (let i = 0; i < len; i++) {
    //单个用户的统计信息
    const stat = {
      _id: Random.id(),
    };
    //增加各个组件的id value
    componentList.forEach((c) => {
      const { fe_id, type, props } = c;
      switch (type) {
        case "questionInput":
          stat[fe_id] = Random.cname();
          break;
        case "questionTextarea":
          stat[fe_id] = Random.cname();
          break;
        case "questionRadio":
          stat[fe_id] = props.options[0].text;
          break;
        case "questionCheckbox":
          stat[fe_id] = `${props.list[0].text},${props.list[1].text}`;
          break;
      }
    });
    res.push(stat);
  }
  return res;
}
module.exports = getStatList;
